package fu.capstone.hanoicityguide.common.utility;

import java.io.File;

import fu.capstone.hanoicityguide.dataaccess.base.BaseDAO;
import fu.capstone.hanoicityguide.dataaccess.base.DatabaseHelper;

public class DAOUtility {

	public DAOUtility() {
		super();
	}

	// validate for insert Home
	public boolean validateInsertHome(int homeId, String overview,
			String history, int albumImageId) {
		if (homeId > 0 && overview.length() <= 2000 && overview.length() > 0
				&& history.length() > 0 && history.length() <= 2000
				&& albumImageId > 0) {
			return true;
		} else {
			return false;
		}
	}

	// validate for insert Category
	public boolean validateInsertCategory(int categoryId, String categoryName) {
		if (categoryId > 0 && categoryName != null
				&& categoryName.length() <= 100 && categoryName.length() > 0) {
			return true;
		} else {
			return false;
		}
	}

	// validate for insert Type
	public boolean validateInsertType(int typeId, int categoryId,
			String typeName) {
		if (typeId > 0 && categoryId > 0 && typeName != null
				&& typeName.length() <= 100 && typeName.length() > 0) {
			return true;
		} else {
			return false;
		}
	}

	// validate for insert AlbumImage
	public boolean validateInsertAlbumImage(int albumImageId, String iconPath,
			String imgPath1, String imgPath2, String imgPath3, String imgPath4,
			String imgPath5) {
		if (albumImageId > 0 && iconPath != null && iconPath.length() <= 500
				&& iconPath.length() > 0 && imgPath1.length() <= 500
				&& imgPath2.length() <= 500 && imgPath3.length() <= 500
				&& imgPath4.length() <= 500 && imgPath5.length() <= 500) {
			return true;
		} else {
			return false;
		}
	}

	// validate for insert Rating
	public boolean validateInsertRating(int ratingId, int ratingValue) {
		if (ratingId > 0 && ratingValue >= 0 && ratingValue <= 5) {
			return true;
		} else {
			return false;
		}
	}

	// validate for insert GeoLocation
	public boolean validateInsertGeoLocation(int geolocationID,
			double geolocationLong, double geolocationLat) {
		if (geolocationID > 0) {
			return true;
		} else {
			return false;
		}
	}

	// validate for insert Class
	public boolean validateInsertClass(int classId, String className) {
		if (classId > 0 && className.length() > 0 && className.length() <= 50) {
			return true;
		} else {
			return false;
		}
	}

	// check for db file existed
	public boolean checkExisted() {
		try {
			String dbPath = "//data//" + "//data//"
					+ "fu.capstone.hanoicityguide" + "//databases//"
					+ DatabaseHelper.DATABASE_NAME;

			// check for dbFile existed
			File dbFile = new File(dbPath);
			if (dbFile.exists()) {
				return true;

			} else {
				return false;
			}
		} catch (Exception e) {
			return false;
		}

	}

}
